// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: implementation of CXFormsElementAction.
//   $Id$


#include "stdafx.h"
#include "xformselementaction.h"
#include "moveOutOfViewlink.h"
#include "XFormsXFormsElement.h"
CXFormsElementAction::CXFormsElementAction(void)
{
}

CXFormsElementAction::~CXFormsElementAction(void)
{
}

HRESULT CXFormsElementAction::render(void)
{
	return S_OK;
}


HRESULT CXFormsElementAction::DocumentReady()
{
	HRESULT hr = __super::DocumentReady();

	CComPtr<IHTMLElement> pEl;
	GetMasterElement(&pEl);
	if(pEl)
	{
		CComPtr<IHTMLDocument2> pDoc2;
		if(m_pXForms)
			m_pXForms->GetOwnerDocument(&pDoc2);
		if(pDoc2)
		{
			CComPtr<IHTMLElement> pBody;
			pDoc2->get_body(&pBody);
			CComQIPtr<IHTMLElement2> pBod2(pBody);
			if(pBod2)
			{
				CComBSTR sPosition(L"afterBegin");
				pBod2->insertAdjacentElement(sPosition,pEl,0);
			}
		}
		CComQIPtr<IHTMLElement2> pEl2(pEl);
		if(pEl2)
		{
			//remove actions from the tabbing order.
			pEl2->put_tabIndex(-1);
		}

	//	MoveOutOfViewlink(pEl);
	}

	return hr;
}


HRESULT CXFormsElementAction::InitBehaviour()
{
	HRESULT hr =  __super::InitBehaviour();
	
	return hr;
}


void CXFormsElementAction::RegisterFindBehaviourRefusal()
{
	//do nothing
#ifdef _DEBUG
	long l = 0;
#endif
}
void CXFormsElementAction::RegisterFindBehaviourAcceptance()
{
	//do nothing
#ifdef _DEBUG
	long l = 0;
#endif
}
